﻿<%--

Copyright (c) 2012 Lucas Agudiez (Agu10)

Online Math Calculator is released under the MIT license.
See the file license.txt for copying permission.





--%>

<%@ Page Title="Online Math Calculator" Language="C#" MasterPageFile="~/Site.master"
    AutoEventWireup="true" CodeBehind="Solve.aspx.cs" Inherits="Online_Math.Solve" %>

<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <p>
        <asp:ScriptManager ID="scriptManager" runat="server">
        </asp:ScriptManager>
    </p>
    <p>
        <br />
        This is an Online Math Calculator. What this does is take your equation in the usual
        MITx form and convert every variable to x, y, and every constant to a, b, c, d,
        e, etc... use wolfram|alpha and then convert back to the input format.</p>
    <p>
    </p>
    <br />
    <br />
    <asp:UpdatePanel ID="showExamplePanel" runat="server">
        <ContentTemplate>
            Example:
            <asp:LinkButton ID="showExampleButton" runat="server" OnClick="showExampleButton_Click">↓ Show Example</asp:LinkButton>
            <br />
            <asp:Image ID="exampleImage" runat="server" ImageUrl="example.png" Visible="False"
                Width="500px" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="updatePanel" runat="server">
        <ContentTemplate>
            <p>
                Insert Query:
                <asp:TextBox ID="inputQueryText" runat="server" Width="400px"></asp:TextBox>
            </p>
            <p>
                Independent Variable (x):
                <asp:TextBox ID="independentVariableText" runat="server"></asp:TextBox>
                <br />
                Dependent Variable (y):
                <asp:TextBox ID="dependentVariableText" runat="server"></asp:TextBox>
            </p>
            <p>
                Constants:&nbsp;
                <asp:Button ID="findConstantsButton" runat="server" OnClick="findConstantsButton_Click"
                    Text="Find Constants" />
                &nbsp;Tries to guess what your constants are... you may have to delete some.<br />
                <table>
                    <tr>
                        <td>
                            <asp:ListBox ID="constantsList" runat="server" Width="172px" Height="294px"></asp:ListBox>
                        </td>
                        <td>
                            <asp:TextBox ID="addConstantText" runat="server" Width="81px"></asp:TextBox>
                            <asp:Button ID="addConstantButton" runat="server" OnClick="addConstantButton_Click"
                                Text="Add Constant" />
                            <br />
                            <br />
                            <asp:Button ID="deleteSelectedButton" runat="server" OnClick="deleteSelectedButton_Click"
                                Text="Delete Selected" />
                            <br />
                            <br />
                            <asp:Button ID="clearAllButton" runat="server" OnClick="clearAllButton_Click" Text="Clear All" />
                        </td>
                    </tr>
                </table>
            </p>
            <p>
                <asp:Button ID="solveButton" runat="server" OnClick="solveButton_Click" OnClientClick="startLoading()"
                    Text="Solve!" />
                &nbsp;<br />
                <br />
            </p>
            <a name="resultsAnchor" id="resultsAnchor"></a>
            <div id="addThisBarPlace">
            </div>
            <p>
                <div id="results">
                    Results:<br />
                    <asp:Label ID="solutionText" runat="server" Text="-"></asp:Label>
                    <br />
                </div>
                <img src="ajax-loader.gif" id="loadingImage" />
                <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
                <script language="javascript">

                    if (window.location.toString().indexOf("localhost") == -1 && window.location.toString().indexOf("math.manifestation") == -1) {
                        window.location = "http://math.manifestation.com.ar";
                    }

                    function onLoaded() {
                        document.getElementById("loadingImage").style.display = "none";
                        try {
                            document.getElementById("addThisBarPlace").innerHTML = document.getElementById("addThisBarFrom").innerHTML;
                        } catch (e) { }
                    }
                    function startLoading() {
                        document.getElementById("loadingImage").style.display = "block";
                        document.getElementById("results").style.display = "none";
                        goToResultsAnchor();
                    }
                    function goToResultsAnchor() {
                        $('html,body').animate({ scrollTop: $("#resultsAnchor").offset().top }, 'slow');
                    }
                    function EndRequestHandler(sender, args) {
                        if (sender._postBackSettings.sourceElement.id.indexOf("solve") >= 0) {
                            goToResultsAnchor();
                        }
                        onLoaded();
                    }
                    onLoaded();
                    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler)
                </script>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%   
    @Response.WriteFile("addThis.html"); 
    %>
</asp:Content>
